package com.miniboy.imageloader_sample;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initWidgets();
    }

    private void initWidgets() {
        Button single = (Button) findViewById(com.miniboy.imageloader_sample.R.id.id_single_btn);
        Button list = (Button) findViewById(com.miniboy.imageloader_sample.R.id.id_list_btn);

        if (single != null) {
            single.setOnClickListener(this);
        }
        if (list != null) {
            list.setOnClickListener(this);
        }
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case com.miniboy.imageloader_sample.R.id.id_single_btn:
                intent = new Intent(this, SingleActivity.class);
                break;
            case com.miniboy.imageloader_sample.R.id.id_list_btn:
                intent = new Intent(this, ListActivity.class);
                break;
        }
        jump2Activity(intent);
    }

    private void jump2Activity(Intent intent) {
        if (intent == null) {
            return;
        }
        startActivity(intent);
    }
}
